<template>
  子组件B
  <button @click="btnClick">子组件B</button>
</template>

<script>
import eventBus from './eventBus'
export default {
  methods: {
    btnClick() {
      console.log('子组件B')
    },
  },
  created() {
    // 监听多个事件
    eventBus.on('foo', num => {
      console.log(num)
    })
    eventBus.on('get', num => {
      console.log(num)
    })
    // 监听全部事件
    eventBus.on('*', (type, info) => {
      console.log(type, info)
    })
    // 取消事件监听
    const get = num => console.log(num)
    eventBus.on('get', get)
    eventBus.off('get', get)
    // eventBus.all.clear()
  }, 
}
</script>

<style scoped></style>
